package com.sui.bigdata.flink.sql.side;

import com.alibaba.fastjson.JSONObject;
import com.sui.bigdata.flink.sql.core.Main;
import org.apache.flink.calcite.shaded.com.google.common.base.Charsets;
import org.apache.flink.calcite.shaded.com.google.common.collect.Lists;
import org.junit.Test;


import java.net.URLEncoder;
import java.sql.Timestamp;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author YongChen
 * @date 2020/3/17 16:12
 * @description
 * @email yong_chen@sui.com
 */
public class CreditAduit {
    @Test
    public void test1() throws Exception {
        String sql = " create scalar function notBlank with com.sui.bigdata.flink.sql.function.scalar.NotBlank;\n" +
                "create scalar function FinAesDecode with com.sui.bigdata.flink.sql.function.scalar.FinAesDecode;\n" +
                "\n" +
                " CREATE TABLE sourc_detection_combine_1(\n" +
                "  request_account varchar,\n" +
                "  business varchar,\n" +
                "  request_data.name varchar as name ,\n" +
                "  request_data.idNum varchar  as idNum,\n" +
                "  response_data.data.companyAddressTag.map.distance                                         varchar as   x2 ,\n" +
                "  response_data.data.homeAddressTag.map.distance                                            varchar as   x3 ,\n" +
                "  response_data.data.companyNameTag.info.cnt                                                varchar as   x8 ,\n" +
                "  response_data.data.companyNameTag.multidebt.rse_co_name_max_overdue_days_duration_in_3m   varchar as   x9 ,\n" +
                "  response_data.data.companyPhoneTag.multidebt.rse_co_tel_apply_in_last_3m_cnt              varchar as   x15,\n" +
                "  response_data.data.companyNameTag.multidebt.rse_co_name_apply_in_last_3m_cnt              varchar as   x17,\n" +
                "  response_data.data.companyNameTag.multidebt.rse_co_name_max_overdue_days_duration_in_1y   varchar as   x19\n" +
                " )WITH(\n" +
                "    type ='kafka',\n" +
                "    bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
                "    offsetReset ='latest',\n" +
                "    groupId = 'detection_combine_1',\n" +
                "    topic ='lc.bigdata.fraud_detection_risk',\n" +
                "    parallelism ='1'\n" +
                " );\n" +
                " \n" +
                " CREATE TABLE sourc_detection_combine_2(\n" +
                "  request_account varchar,\n" +
                "  business varchar,\n" +
                "  request_data.name varchar as name ,\n" +
                "  request_data.idNum varchar  as idNum,\n" +
                "  response_data.data.companyPhoneTag.multidebt.rse_co_tel_apply_in_last_1m_cnt              varchar as   x21,\n" +
                "  response_data.data.mobileTag.multidebt.rse_phone_apply_in_last_3m_cnt                     varchar as   x22,\n" +
                "  response_data.data.contactsamobileTag.alipay.is_match                                     varchar as   x24,\n" +
                "  response_data.data.companyNameTag.multidebt.rse_co_name_loan_in_last_3m_cnt               varchar as   x26,\n" +
                "  response_data.data.mobileTag.alipay.is_match                                              varchar as   x27,\n" +
                "  response_data.data.companyNameTag.multidebt.rse_co_name_max_overdue_days_duration_in_6m   varchar as   x28,\n" +
                "  response_data.data.companyNameTag.multidebt.rse_co_name_apply_in_last_1m_cnt              varchar as   x29,\n" +
                "  response_data.data.contactsbmobileTag.alipay.is_match                                     varchar as   x31\n" +
                " )WITH(\n" +
                "    type ='kafka',\n" +
                "    bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
                "    offsetReset ='latest',\n" +
                "    groupId = 'detection_combine_2',\n" +
                "    topic ='lc.bigdata.fraud_detection_risk',\n" +
                "    parallelism ='1'\n" +
                " );\n" +
                "\n" +
                " CREATE TABLE sourc_detection_combine_3(\n" +
                "  request_account varchar,\n" +
                "  business varchar,\n" +
                "  request_data.name varchar as name ,\n" +
                "  request_data.idNum varchar  as idNum,\n" +
                "  response_data.data.mobileTag.multidebt.rse_phone_loan_in_last_3m_cnt                      varchar as   x32,\n" +
                "  response_data.data.companyNameTag.multidebt.rse_co_name_max_overdue_days_in_3m            varchar as   x34,\n" +
                "  response_data.data.companyPhoneTag.multidebt.rse_co_tel_loan_in_last_3d_cnt               varchar as   x35,\n" +
                "  response_data.data.companyNameTag.multidebt.rse_co_name_apply_in_last_7d_cnt              varchar as   x36,\n" +
                "  response_data.data.companyNameTag.multidebt.rse_co_name_loan_in_last_1m_cnt               varchar as   x37,\n" +
                "  response_data.data.companyPhoneTag.multidebt.rse_co_tel_loan_in_last_7d_cnt               varchar as   x38,\n" +
                "  response_data.data.mobileTag.multidebt.rse_phone_loan_in_last_1m_cnt                      varchar as   x39,\n" +
                "  response_data.data.companyPhoneTag.multidebt.rse_co_tel_loan_in_last_1m_cnt               varchar as   x40\n" +
                " )WITH(\n" +
                "    type ='kafka',\n" +
                "    bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
                "    offsetReset ='latest',\n" +
                "    groupId = 'detection_combine_3',\n" +
                "    topic ='lc.bigdata.fraud_detection_risk',\n" +
                "    parallelism ='1'\n" +
                " );\n" +
                "\n" +
                " \n" +
                "CREATE TABLE general_query_action(\n" +
                "    businessid                                    varchar as  businessid,\n" +
                "    qaccount                                      varchar as qaccount,\n" +
                "    queryparma.variables.suid                     varchar as   suid, \n" +
                "    data[0].exp_yh_userkn_name_unusual_rate       varchar as   x1  , \n" +
                "    data[0].exp_yh_userkn_phone_head_5_hhi        varchar as   x4  , \n" +
                "    data[0].exp_yh_userkn_phone_isp_rate          varchar as   x5  , \n" +
                "    data[0].exp_yh_userkn_phone_all               varchar as   x6  , \n" +
                "    data[0].exp_yh_userkn_phone_head_6_hhi        varchar as   x7  , \n" +
                "    data[0].exp_yh_userkn_phone_4_4_hhi           varchar as   x10 , \n" +
                "    data[0].exp_yh_userkn_phone_head_8_hhi        varchar as   x11 , \n" +
                "    data[0].exp_yh_userkn_phone_head_7_hhi        varchar as   x12 , \n" +
                "    data[0].exp_yh_userkn_phone_head_9_hhi        varchar as   x13 , \n" +
                "    data[0].exp_yh_userkn_phone_unusual_rate      varchar as   x14 , \n" +
                "    data[0].exp_yh_userkn_phone_7_4_hhi           varchar as   x16 , \n" +
                "    data[0].exp_yh_high_risk_numericermediary_tag varchar as   x18 , \n" +
                "    data[0].exp_yh_user_call_log_group            varchar as   x20 , \n" +
                "    data[0].exp_yh_userkn_name_unusual_rate_jud   varchar as   x23 , \n" +
                "    data[0].exp_yh_userkn_phone_unusual_rate_jud  varchar as   x25 , \n" +
                "    data[0].exp_yh_userkn_phone_head_9_hhi_jud    varchar as   x30 , \n" +
                "    data[0].exp_yh_userkn_phone_head_5_hhi_jud    varchar as   x33  \n" +
                ")WITH(                                           \n" +
                "   type ='kafka', \n" +
                "   bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093', \n" +
                "   offsetReset ='latest', \n" +
                "   groupId = 'general_query_action_cy', \n" +
                "   topic ='lc.bigdata.ls_general_query_action', \n" +
                "   parallelism ='1' \n" +
                ");  \n" +
                "\n" +
                "\n" +
                "CREATE TABLE bdl_suigo_loan_customer_info(\n" +
                "  rowData.ssj_name varchar as suid,\n" +
                "  rowData.name varchar as name,\n" +
                "  rowData.id_no varchar as  id_num\n" +
                " )WITH(\n" +
                "    type ='kafka',\n" +
                "    bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
                "    offsetReset ='latest',\n" +
                "    groupId = 'bdl_suigo_loan_customer_info_20200320',\n" +
                "    topic ='rtsync.bdl_suigo_loan_customer_info',\n" +
                "    parallelism ='1'\n" +
                " );\n" +
                " \n" +
                "CREATE TABLE sink_detection_combine_1(  \n" +
                "  info:rowkey  varchar,\n" +
                "  info:name_idnum varchar,\n" +
                "  info:x2   varchar,\n" +
                "  info:x3   varchar,\n" +
                "  info:x8   varchar,\n" +
                "  info:x9   varchar,\n" +
                "  info:x15  varchar,\n" +
                "  info:x17  varchar,\n" +
                "  info:x19  varchar\n" +
                " ) WITH (  \n" +
                "    type='hbase',  \n" +
                "    zookeeperQuorum='10.201.7.114:2181,10.201.7.115:2181,10.201.7.113:2181',  \n" +
                "    zookeeperParent = '/hbase',  \n" +
                "    tableName='adl_bd_ls_credit_aduit_tag',  \n" +
                "    rowkey='info:rowkey'); \n" +
                " \n" +
                "CREATE TABLE sink_detection_combine_2(  \n" +
                "  info:rowkey  varchar,\n" +
                "  info:name_idnum varchar,\n" +
                "  info:x21  varchar,\n" +
                "  info:x22  varchar,\n" +
                "  info:x24  varchar,\n" +
                "  info:x26  varchar,\n" +
                "  info:x27  varchar,\n" +
                "  info:x28  varchar,\n" +
                "  info:x29  varchar,\n" +
                "  info:x31  varchar\n" +
                " ) WITH (  \n" +
                "    type='hbase',  \n" +
                "    zookeeperQuorum='10.201.7.114:2181,10.201.7.115:2181,10.201.7.113:2181',  \n" +
                "    zookeeperParent = '/hbase',  \n" +
                "    tableName='adl_bd_ls_credit_aduit_tag',  \n" +
                "    rowkey='info:rowkey');\t \n" +
                " \n" +
                "CREATE TABLE sink_detection_combine_3(  \n" +
                "  info:rowkey  varchar,\n" +
                "  info:name_idnum varchar,\n" +
                "  info:x32  varchar,\n" +
                "  info:x34  varchar,\n" +
                "  info:x35  varchar,\n" +
                "  info:x36  varchar,\n" +
                "  info:x37  varchar,\n" +
                "  info:x38  varchar,\n" +
                "  info:x39  varchar,\n" +
                "  info:x40  varchar\n" +
                " ) WITH (  \n" +
                "    type='hbase',  \n" +
                "    zookeeperQuorum='10.201.7.114:2181,10.201.7.115:2181,10.201.7.113:2181',  \n" +
                "    zookeeperParent = '/hbase',  \n" +
                "    tableName='adl_bd_ls_credit_aduit_tag',  \n" +
                "    rowkey='info:rowkey');\n" +
                "\n" +
                " CREATE TABLE sink_customer_info(  \n" +
                "  info:rowkey  varchar,\n" +
                "  info:suid varchar,\n" +
                "  info:name_idnum  varchar\n" +
                " ) WITH (  \n" +
                "    type='hbase',  \n" +
                "    zookeeperQuorum='10.201.7.114:2181,10.201.7.115:2181,10.201.7.113:2181',  \n" +
                "    zookeeperParent = '/hbase',  \n" +
                "    tableName='adl_bd_ls_credit_aduit_tag',  \n" +
                "    rowkey='info:rowkey');\t\n" +
                "\t\n" +
                "\n" +
                "CREATE TABLE credit_aduit_tag_side (   \n" +
                "   info:suid_md5 varchar as suid_md5,  \n" +
                "   info:name_idnum varchar as name_idnum,  \n" +
                "   PRIMARY KEY (suid_md5),  \n" +
                "   PERIOD FOR SYSTEM_TIME ) WITH   \n" +
                "  (type = 'hbase',  \n" +
                "   zookeeperQuorum = '10.201.7.114:2181,10.201.7.115:2181,10.201.7.113:2181',  \n" +
                "   zookeeperParent = '/hbase',  \n" +
                "   tableName = 'adl_bd_ls_credit_aduit_tag');\t\n" +
                "\t\n" +
                "\t\n" +
                "CREATE TABLE sink_general_query_action(  \n" +
                "  info:rowkey  varchar,\n" +
                "  info:name_idnum varchar,\n" +
                "  info:x1   varchar,\n" +
                "  info:x4   varchar,\n" +
                "  info:x5   varchar,\n" +
                "  info:x6   varchar,\n" +
                "  info:x7   varchar,\n" +
                "  info:x10  varchar,\n" +
                "  info:x11  varchar,\n" +
                "  info:x12  varchar,\n" +
                "  info:x13  varchar,\n" +
                "  info:x14  varchar,\n" +
                "  info:x16  varchar,\n" +
                "  info:x18  varchar,\n" +
                "  info:x20  varchar,\n" +
                "  info:x23  varchar,\n" +
                "  info:x25  varchar,\n" +
                "  info:x30  varchar,\n" +
                "  info:x33  varchar\n" +
                " ) WITH (  \n" +
                "    type='hbase',  \n" +
                "    zookeeperQuorum='10.201.7.114:2181,10.201.7.115:2181,10.201.7.113:2181',  \n" +
                "    zookeeperParent = '/hbase',  \n" +
                "    tableName='adl_bd_ls_credit_aduit_tag',  \n" +
                "    rowkey='info:rowkey');\t\n" +
                "\t\t\n" +
                " insert into sink_detection_combine_1\n" +
                " SELECT  \n" +
                "    md5(concat(name ,'#',idNum)) as rowkey , \n" +
                "\tconcat(name ,'#',idNum) as name_idnum,\n" +
                "    (case when  NotBlank(x2)   then x2  else '-1' end) as  x2 , \n" +
                "    (case when  NotBlank(x3)   then x3  else '-1' end) as  x3 , \n" +
                "    (case when  NotBlank(x8)   then x8  else '-1' end) as  x8 , \n" +
                "    (case when  NotBlank(x9)   then x9  else '-1' end) as  x9 , \n" +
                "    (case when  NotBlank(x15)  then x15 else '-1' end) as  x15, \n" +
                "    (case when  NotBlank(x17)  then x17 else '-1' end) as  x17, \n" +
                "    (case when  NotBlank(x19)  then x19 else '-1' end) as  x19\n" +
                " from sourc_detection_combine_1  \n" +
                " where NotBlank(name) and NotBlank(idNum) and request_account ='bd_pd' and business='risk';  \n" +
                " \n" +
                " insert into sink_detection_combine_2\n" +
                " SELECT  \n" +
                "    md5(concat(name ,'#',idNum)) as rowkey , \n" +
                "\tconcat(name ,'#',idNum) as name_idnum,\n" +
                "    (case when NotBlank(x21)  then x21 else '-1'end) as  x21, \n" +
                "    (case when NotBlank(x22)  then x22 else '-1'end) as  x22, \n" +
                "    (case when NotBlank(x24)  then x24 else '-1'end) as  x24, \n" +
                "    (case when NotBlank(x26)  then x26 else '-1'end) as  x26,\n" +
                "\t(case when NotBlank(x27)  then x27 else '-1'end) as  x27, \n" +
                "    (case when NotBlank(x28)  then x28 else '-1'end) as  x28, \n" +
                "    (case when NotBlank(x29)  then x29 else '-1'end) as  x29, \n" +
                "    (case when NotBlank(x31)  then x31 else '-1'end) as  x31\n" +
                " from sourc_detection_combine_2  \n" +
                " where NotBlank(name) and NotBlank(idNum) and request_account ='bd_pd' and business='risk'; \n" +
                " \n" +
                " insert into sink_detection_combine_3\n" +
                " SELECT  \n" +
                "    md5(concat(name ,'#',idNum)) as rowkey , \n" +
                "\tconcat(name ,'#',idNum) as name_idnum,\n" +
                "    (case when NotBlank(x32)  then x32 else '-1' end) as x32, \n" +
                "    (case when NotBlank(x34)  then x34 else '-1' end) as x34, \n" +
                "    (case when NotBlank(x35)  then x35 else '-1' end) as x35, \n" +
                "    (case when NotBlank(x36)  then x36 else '-1' end) as x36, \n" +
                "    (case when NotBlank(x37)  then x37 else '-1' end) as x37, \n" +
                "    (case when NotBlank(x38)  then x38 else '-1' end) as x38, \n" +
                "    (case when NotBlank(x39)  then x39 else '-1' end) as x39, \n" +
                "    (case when NotBlank(x40)  then x40 else '-1' end) as x40  \n" +
                " from sourc_detection_combine_3  \n" +
                " where NotBlank(name) and NotBlank(idNum) and request_account ='bd_pd' and business='risk'; \n" +
                "\n" +
//                "insert into  sink_general_query_action\n" +
                "SELECT  \n" +
                "    md5(t2.name_idnum) as rowkey,\n" +
                "\tt2.name_idnum as name_idnum,\n" +
                "\tt1.x1 ,t1.x4 ,t1.x5 ,t1.x6 ,t1.x7 ,t1.x10,t1.x11,t1.x12,t1.x13,t1.x14,t1.x16,t1.x18,t1.x20,t1.x23,t1.x25,t1.x30,t1.x33 \n" +
                "from (SELECT  \n" +
                "      md5(suid) as suid_md5,\n" +
                "     (case when NotBlank(x1)   then  x1   else '-1' end) as  x1 , \n" +
                "     (case when NotBlank(x4)   then  x4   else '-1' end) as  x4 , \n" +
                "     (case when NotBlank(x5)   then  x5   else '-1' end) as  x5 , \n" +
                "     (case when NotBlank(x6)   then  x6   else '-1' end) as  x6 , \n" +
                "     (case when NotBlank(x7 )  then  x7   else '-1' end) as  x7 , \n" +
                "     (case when NotBlank(x10)  then  x10  else '-1' end) as  x10, \n" +
                "     (case when NotBlank(x11)  then  x11  else '-1' end) as  x11, \n" +
                "     (case when NotBlank(x12)  then  x12  else '-1' end) as  x12, \n" +
                "     (case when NotBlank(x13)  then  x13  else '-1' end) as  x13, \n" +
                "     (case when NotBlank(x14)  then  x14  else '-1' end) as  x14, \n" +
                "     (case when NotBlank(x16)  then  x16  else '-1' end) as  x16, \n" +
                "     (case when NotBlank(x18)  then  x18  else '-1' end) as  x18, \n" +
                "     (case when NotBlank(x20)  then  x20  else '-1' end) as  x20, \n" +
                "     (case when NotBlank(x23)  then  x23  else '-1' end) as  x23, \n" +
                "     (case when NotBlank(x25)  then  x25  else '-1' end) as  x25, \n" +
                "     (case when NotBlank(x30)  then  x30  else '-1' end) as  x30, \n" +
                "     (case when NotBlank(x33)  then  x33  else '-1' end) as  x33  \n" +
                "  from general_query_action\n" +
                "  where NotBlank(suid) and  businessid = 'loan-antifraudnew' and qaccount='ssj_isd') t1 \n" +
                "join credit_aduit_tag_side t2 on t1.suid_md5 = t2.suid_md5;\n" +
                " \n" +
                " \n" +
                "insert into  sink_customer_info\n" +
                "select  \n" +
                "   md5(suid) as rowkey,\n" +
                "   suid,\n" +
                "   concat(name,'#',FinAesDecode(id_num,'ed5e62c607c7c2e441817518ba9ad16bc635aaf93146c5fd3cf8985bf858f0ce')) as name_idnum\n" +
                "from  bdl_suigo_loan_customer_info\n" +
                "where NotBlank(name) and NotBlank(id_num) and NotBlank(suid) and  NotBlank(FinAesDecode(id_num,'ed5e62c607c7c2e441817518ba9ad16bc635aaf93146c5fd3cf8985bf858f0ce'));\n" +
                "\n ";



        exec(sql);
    }


    @Test
    public void test2() throws Exception {
        String sql ="CREATE TABLE bdl_risk_variable_in_param_source (\n" +
                "  businessCode varchar as business_code,\n" +
                "  paramsInfo.bizNo  varchar as biz_no,\n" +
                "  paramsInfo.phone  varchar as phone,\n" +
                "  paramsInfo.userId  varchar as user_id,\n" +
                "  paramsInfo.userName  varchar as user_name,\n" +
                "  phone_data varchar as phone_data,\n" +
                "  event_time timestamp,\n" +
                "  WATERMARK  FOR event_time AS withOffset(event_time, 0)\n" +
                ") WITH\n" +
                "(\n" +
                "   type = 'kafka',\n" +
                "   bootstrapServers = '10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
                "   groupId = 'fin.data.variable.params.yuxin_yyy',\n" +
                "   topic = 'fin.data.variable.params.yuxin_yyy',\n" +
                "   timezone='UTC',\n" +
                "   offsetReset ='latest',\n" +
                "   parallelism = '1'\n" +
                ");\n" +
                "\n" +
                "\n" +
                "CREATE TABLE stg_credit_center_loan_t_user_emergy_contact_side(\n" +
                "  phone varchar,\n" +
                "  user_id varchar,\n" +
                "  name varchar,\n" +
                "  create_time varchar,\n" +
                "  PRIMARY KEY(user_id),\n" +
                "  PERIOD FOR SYSTEM_TIME\n" +
                ") WITH (\n" +
                "   type = 'kudu',\n" +
                "   kuduMasters = '10.201.7.125:7051,10.201.7.123:7051,10.201.7.124:7051',\n" +
                "   tableName = 'impala::dw.flink_test'\n" +
                "   ,cache = 'LRU'\n" +
                "  -- ,partitionedJoin = 'true'\n" +
                ");\n" +
                "\n" +
                "\n" +
                " SELECT\n" +
                "     p.biz_no,\n" +
                "     p.business_code,\n" +
                "     cast(count(1) as varchar) as tag_test_1\n" +
                " from (\n" +
                "      select s.biz_no, s.business_code, s.event_time , c.phone\n" +
                "      from bdl_risk_variable_in_param_source s\n" +
                "      inner join stg_credit_center_loan_t_user_emergy_contact_side c on  c.user_id = s.user_id\n" +
                "  ) p\n" +
                " group by TUMBLE(p.event_time, INTERVAL '3' SECOND), p.biz_no, p.business_code";



        exec(sql);

    }

    @Test
    public void test3() throws Exception {
       String sql = "create scalar function NotBlank with com.sui.bigdata.flink.sql.function.scalar.NotBlank;\n" +
               "CREATE TABLE behaviour_common(\n" +
               "    ssjid varchar,\n" +
               "    event_time varchar,\n" +
               "    title varchar ,\n" +
               "    etype varchar,\n" +
               "    sku varchar\n" +
               " )WITH(\n" +
               "    type ='kafka',\n" +
               "    bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
               "    offsetReset ='latest',\n" +
               "    groupid ='fin_behaviour_common_2020/5/6',\n" +
               "    topic ='lc.financing.behaviour_common',\n" +
               "    parallelism ='1'\n" +
               " );\n" +
               " \n" +
               " \n" +
               " CREATE TABLE bdl_finance_zbank_account_account(\n" +
               "    rowData.ssj_id varchar as ssj_id,\n" +
               "    rowData.create_time varchar as create_time ,\n" +
               "    rowData.account_status varchar as account_status\n" +
               " )WITH(\n" +
               "    type ='kafka',\n" +
               "    bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
               "    offsetReset ='latest',\n" +
               "    groupid ='bdl_finance_zbank_account_account_2020/5/6',\n" +
               "    topic ='rtsync.bdl_finance_zbank_account_account',\n" +
               "    parallelism ='1'\n" +
               " );\n" +
               " \n" +
               " \n" +
               " CREATE TABLE bdl_finance_zbank_trade_account_order(\n" +
               "    rowData.ssj_id varchar as ssj_id,\n" +
               "    rowData.order_finish_time varchar as order_finish_time ,\n" +
               "    rowData.order_status varchar as order_status,\n" +
               "\trowData.trade_type varchar as trade_type,\n" +
               "\trowData.product_code varchar as product_code\n" +
               " )WITH(\n" +
               "    type ='kafka',\n" +
               "    bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
               "    offsetReset ='latest',\n" +
               "    groupid ='bdl_finance_zbank_trade_account_order_2020/5/6',\n" +
               "    topic ='rtsync.bdl_finance_zbank_trade_account_order',\n" +
               "    parallelism ='1'\n" +
               " );\n" +
               " \n" +
               " \n" +
               "  CREATE TABLE bdl_finance_zbank_trade_order(\n" +
               "    rowData.ssj_id varchar as ssj_id,\n" +
               "    rowData.create_time varchar as create_time ,\n" +
               "    rowData.order_status varchar as order_status,\n" +
               "\trowData.trade_type varchar as trade_type,\n" +
               "\trowData.product_code varchar as product_code\n" +
               " )WITH(\n" +
               "    type ='kafka',\n" +
               "    bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
               "    offsetReset ='latest',\n" +
               "    groupid ='bdl_finance_zbank_trade_account_order_2020/5/6',\n" +
               "    topic ='rtsync.bdl_finance_zbank_trade_order',\n" +
               "    parallelism ='1'\n" +
               " );\n" +
               " \n" +
               " \n" +
               "CREATE TABLE sideTable (\n" +
               "   user_id varchar ,\n" +
               "   suid varchar ,\n" +
               "   PRIMARY KEY(user_id),\n" +
               "   PERIOD FOR SYSTEM_TIME\n" +
               " ) WITH (\n" +
               " type='mysql',\n" +
               " url='jdbc:mysql://tidb1.testfeideedba.com:4000/dt?useUnicode=true&amp;characterEncoding=utf8;useSSL=true',\n" +
               " userName='DSJ_user',\n" +
               " password='606cde3507b026H,dHb_77e67H_e',\n" +
               " tableName='adl_bd_ls_ssj_kn_userid_udid_suid_tidb',\n" +
               " maxPoolSize = '100' , \n" +
               " checkOutTimeout = '100000');\n" +
               " \n" +
               "CREATE TABLE view_product_page(\n" +
               "     udidmd5 varchar,\n" +
               "     sid varchar,\n" +
               "     hbase_table varchar,\n" +
               "     userssj_zbank_view_product_page_at_last_time varchar\n" +
               "  )WITH(\n" +
               "     type ='kafka',\n" +
               "     bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
               "     topic ='rttag.realtime.tag_total',\n" +
               "     parallelism ='1'\n" +
               "  );\n" +
               "  \n" +
               "  CREATE TABLE open_account(\n" +
               "     udidmd5 varchar,\n" +
               "     sid varchar,\n" +
               "     hbase_table varchar,\n" +
               "     userssj_zbank_open_account_at_last_time varchar\n" +
               "  )WITH(\n" +
               "     type ='kafka',\n" +
               "     bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
               "     topic ='rttag.realtime.tag_total',\n" +
               "     parallelism ='1'\n" +
               "  );\n" +
               "  \n" +
               "  \n" +
               "  CREATE TABLE recharge(\n" +
               "     udidmd5 varchar,\n" +
               "     sid varchar,\n" +
               "     hbase_table varchar,\n" +
               "     userssj_zbank_recharge_at_last_time varchar\n" +
               "  )WITH(\n" +
               "     type ='kafka',\n" +
               "     bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
               "     topic ='rttag.realtime.tag_total',\n" +
               "     parallelism ='1'\n" +
               "  );\n" +
               "  \n" +
               "  \n" +
               "  CREATE TABLE deposit(\n" +
               "     udidmd5 varchar,\n" +
               "     sid varchar,\n" +
               "     hbase_table varchar,\n" +
               "     userssj_zbank_deposit_at_last_time varchar\n" +
               "  )WITH(\n" +
               "     type ='kafka',\n" +
               "     bootstrapServers ='10.201.7.187:9093,10.201.7.188:9093,10.201.7.189:9093,10.201.7.190:9093',\n" +
               "     topic ='rttag.realtime.tag_total',\n" +
               "     parallelism ='1'\n" +
               "  ); \n" +
               " \n" +
               "insert into  view_product_page\n" +
               "select md5(trim(t2.suid)) as udidmd5,\n" +
               "      trim(t2.suid) as sid ,\n" +
               "\t  'ssj_user_tagging' as hbase_table,\n" +
               "\t  t1.event_time as userssj_zbank_view_product_page_at_last_time \n" +
               "from (select ssjid as ssj_id,max(substring(event_time,1,19)) as event_time\n" +
               "     from behaviour_common \n" +
               "     where title like '产品详情页%' and  LOWER(etype) = 'view' and sku in ('bank_zb','zbank') and NotBlank(ssjid)\n" +
               "     group by ssjid) t1 \n" +
               "join sideTable t2 on t1.ssj_id = t2.user_id;\n" +
               "\n" +
               "\n" +
               "insert into  open_account\n" +
               "select md5(trim(n2.suid)) as udidmd5,\n" +
               "       trim(n2.suid) as sid,\n" +
               "\t   'ssj_user_tagging' as hbase_table,\n" +
               "       n1.create_time as  userssj_zbank_open_account_at_last_time\n" +
               "from (select ssj_id,max(create_time) as create_time\n" +
               "      from bdl_finance_zbank_account_account\n" +
               "      where account_status = '1' and  NotBlank(ssj_id)\n" +
               "      group by ssj_id) n1 \n" +
               "join sideTable n2 on n1.ssj_id = n2.user_id;\n" +
               "\n" +
               "\n" +
               "insert into recharge\n" +
               "select md5(trim(m2.suid)) as udidmd5,\n" +
               "     trim(m2.suid) as sid,\n" +
               "\t 'ssj_user_tagging' as hbase_table,\n" +
               "\t m1.order_finish_time  as  userssj_zbank_recharge_at_last_time \n" +
               "from (select ssj_id,max(order_finish_time) as order_finish_time\n" +
               "     from  bdl_finance_zbank_trade_account_order\n" +
               "     where order_status = '2' and  trade_type = '1' and  lower(product_code)='zbank' and NotBlank(ssj_id)\n" +
               "     group by ssj_id) m1 \n" +
               "join sideTable m2 on m1.ssj_id = m2.user_id;\n" +
               "\n" +
               "\n" +
               "insert into deposit\n" +
               "select \n" +
               "     md5(trim(k2.suid)) as udidmd5,\n" +
               "     trim(k2.suid) as sid,\n" +
               "\t 'ssj_user_tagging' as hbase_table,\n" +
               "     k1.create_time as userssj_zbank_deposit_at_last_time\n" +
               "from(select ssj_id,max(create_time) as create_time\n" +
               "     from  bdl_finance_zbank_trade_order\n" +
               "     where order_status = '2' and  trade_type = '1' and  lower(product_code)='zbank' and NotBlank(ssj_id)\n" +
               "     group by ssj_id) k1 \n" +
               "join sideTable k2 on k1.ssj_id = k2.user_id;\n" +
               "\n" +
               "\n" +
               "\n" +
               "\n" +
               "\n" +
               "\n" +
               "\n" +
               "\n" +
               " \n" ;


        exec(sql);

    }

    public void exec(String sql) throws Exception {
        List<String> paramList = Lists.newArrayList();
        paramList.add("-sql");
        String exeSql = URLEncoder.encode(sql, Charsets.UTF_8.name());
        paramList.add(exeSql);
        paramList.add("-name");
        paramList.add("xc");
        paramList.add("-mode");
        paramList.add("local");
        paramList.add("-port");
        paramList.add("8081");
        paramList.add("-confProp");
        String conf = "{\"time.characteristic\":\"EventTime\",\"parallelism\":1}";
        String confEncode = URLEncoder.encode(conf, Charsets.UTF_8.name());
        paramList.add(confEncode);

        String[] params = new String[paramList.size()];
        paramList.toArray(params);
        Main.main(params);
    }

    @Test
    public void test6() throws Exception {
//        String str = "{\"requestId\":\"f286ac36a9064002a9c2f4b80fc2297f\",\"code\":200,\"msg\":\"成功\",\"data\":{\"companyAddress\":\"重庆市江北区鱼嘴镇\",\"companyAddressTag\":{\"address\":{\"e_commerce_addr_last_3m_jud\":-1,\"yuxin_reg_addr_jud\":-1,\"e_commerce_addr_latest_jud\":-1,\"active_addr_last_3m_jud\":-1,\"active_addr_last_6m_jud\":-1,\"e_commerce_addr_last_1m_jud\":-1,\"e_commerce_addr_last_6m_jud\":-1,\"active_addr_last_1m_jud\":-1},\"map\":{\"distance\":1}},\"companyName\":\"中信保安公司\",\"companyNameTag\":{\"company\":[]},\"companyPhone\":\"13648338004\",\"companyPhoneTag\":{\"phone\":{\"channel\":\"2\",\"sp\":\"移动\",\"province\":\"重庆\",\"city\":\"重庆\",\"tag\":[],\"isVirtualNo\":\"0\"}},\"contactsAMobile\":\"18323164083\",\"contactsAMobileTag\":{\"multiDebt\":{\"rse_phone_apply_in_last_1m_cnt\":0,\"rse_phone_apply_in_last_7d_cnt\":0,\"rse_phone_loan_in_last_3m_cnt\":0,\"rse_phone_apply_in_last_3d_cnt\":0,\"rse_phone_apply_in_last_3m_cnt\":0,\"rse_phone_loan_in_last_1m_cnt\":0,\"rse_phone_loan_in_last_3d_cnt\":0,\"rse_phone_loan_in_last_7d_cnt\":0},\"phone\":{\"channel\":\"2\",\"sp\":\"移动\",\"province\":\"重庆\",\"city\":\"重庆\",\"tag\":[],\"isVirtualNo\":\"0\"}},\"contactsBMobile\":\"17303790806\",\"contactsBMobileTag\":{\"phone\":{\"channel\":\"2\",\"sp\":\"电信\",\"province\":\"河南\",\"city\":\"洛阳\",\"tag\":[],\"isVirtualNo\":\"0\"}},\"homeAddress\":\"重庆市江北区鱼嘴镇\",\"homeAddressTag\":{\"address\":{\"e_commerce_addr_last_3m_jud\":-1,\"yuxin_reg_addr_jud\":-1,\"e_commerce_addr_latest_jud\":-1,\"active_addr_last_3m_jud\":-1,\"active_addr_last_6m_jud\":-1,\"e_commerce_addr_last_1m_jud\":-1,\"e_commerce_addr_last_6m_jud\":-1,\"active_addr_last_1m_jud\":-1},\"map\":{\"distance\":1}},\"idNum\":\"500105199612035850\",\"idNumTag\":{\"multiDebt\":{\"rse_id_loan_in_last_7d_cnt\":0,\"rse_id_apply_in_last_1m_cnt\":0,\"rse_id_apply_in_last_3d_cnt\":0,\"rse_id_loan_in_last_3m_cnt\":0,\"rse_id_apply_in_last_7d_cnt\":0,\"rse_id_apply_in_last_3m_cnt\":0,\"rse_id_loan_in_last_1m_cnt\":0,\"rse_id_loan_in_last_3d_cnt\":0},\"review\":{\"rse_phone_related_to_id_cnt\":1}},\"mobile\":\"15723206271\",\"mobileTag\":{\"multiDebt\":{\"rse_phone_apply_in_last_1m_cnt\":0,\"rse_phone_apply_in_last_7d_cnt\":0,\"rse_phone_loan_in_last_3m_cnt\":0,\"rse_phone_apply_in_last_3d_cnt\":0,\"rse_phone_apply_in_last_3m_cnt\":0,\"rse_phone_loan_in_last_1m_cnt\":0,\"rse_phone_loan_in_last_3d_cnt\":0,\"rse_phone_loan_in_last_7d_cnt\":0},\"phone\":{\"channel\":\"2\",\"sp\":\"移动\",\"province\":\"重庆\",\"city\":\"重庆\",\"tag\":[],\"isVirtualNo\":\"0\"},\"review\":{\"rse_id_related_to_phone_cnt\":1}},\"reportId\":\"N20190430153109312\",\"reportTime\":\"2019-04-30 15:31:09\"}} ";
//        String data = JSONObject.parseObject(str);
//        jsonObject.get("multiDebt"));

//        String msg2 = "{\"serialid\":\"84f018fa4eba48c481e477fba1b5baa9\",\"businessid\":\"loan-mutex\",\"queryparma\":\"{\\\"businessId\\\":\\\"loan-mutex\\\",\\\"conditions\\\":[{\\\"queryId\\\":[\\\"u_n2z1rwu\\\"],\\\"queryType\\\":[\\\"11\\\"]}]}\",\"qaccount\":\"data_team\",\"code\":\"0\",\"data\":\"[{\\\"ReasonCodes[20]\\\":\\\"\\\",\\\"ReasonCodeDescs[10]\\\":\\\"\\\",\\\"ReasonName[1]\\\":\\\"福贷通过\\\",\\\"ReasonCodes[12]\\\":\\\"\\\",\\\"ReasonCodeDescs[14]\\\":\\\"\\\",\\\"ruidai_status\\\":\\\"\\\",\\\"ReasonName[5]\\\":\\\"\\\",\\\"ReasonName[11]\\\":\\\"\\\",\\\"ReasonCodes[7]\\\":\\\"\\\",\\\"ReasonName[9]\\\":\\\"\\\",\\\"ReasonName[19]\\\":\\\"\\\",\\\"fudai_status\\\":\\\"100010\\\",\\\"ReasonCodes[6]\\\":\\\"\\\",\\\"ReasonName[15]\\\":\\\"\\\",\\\"Version\\\":\\\"FDANDRUI-20191224-V8\\\",\\\"ReasonCodes[2]\\\":\\\"1001\\\",\\\"ReasonCodes[17]\\\":\\\"\\\",\\\"ReasonCodeDescs[18]\\\":\\\"\\\",\\\"ruidai_new_user\\\":\\\"1\\\",\\\"ReasonCodeDescs[3]\\\":\\\"A\\\",\\\"ReasonCodeDescs[7]\\\":\\\"\\\",\\\"ruidai_putout_status\\\":\\\"\\\",\\\"ReasonCodes[13]\\\":\\\"\\\",\\\"ReasonCodeDescs[13]\\\":\\\"\\\",\\\"ReasonName[4]\\\":\\\"\\\",\\\"ReasonName[12]\\\":\\\"\\\",\\\"ReasonName[20]\\\":\\\"\\\",\\\"ReasonName[8]\\\":\\\"\\\",\\\"ReasonCodes[5]\\\":\\\"\\\",\\\"nocard_credit_limit\\\":0.0,\\\"fudai_credit_limit\\\":0.0,\\\"ruidai_check\\\":\\\"Y\\\",\\\"ReasonName[16]\\\":\\\"\\\",\\\"DecisionResultCodes\\\":\\\"\\\",\\\"ReasonCodes[1]\\\":\\\"1003\\\",\\\"ReasonCodeDescs[17]\\\":\\\"\\\",\\\"ReasonCodeDescs[2]\\\":\\\"A\\\",\\\"ReasonCodes[18]\\\":\\\"\\\",\\\"ReasonCodeDescs[6]\\\":\\\"\\\",\\\"ReasonCodeDescs[20]\\\":\\\"\\\",\\\"ReasonCodeDescs[9]\\\":\\\"\\\",\\\"ReasonCodes[10]\\\":\\\"\\\",\\\"fudai_orig_status\\\":\\\"-2\\\",\\\"fudai_new_user\\\":\\\"1\\\",\\\"ReasonCodeDescs[12]\\\":\\\"\\\",\\\"ReasonCodes[14]\\\":\\\"\\\",\\\"ReasonName[3]\\\":\\\"无卡瑞贷通过\\\",\\\"nocard_new_user\\\":\\\"1\\\",\\\"fudai_check\\\":\\\"Y\\\",\\\"ReasonName[7]\\\":\\\"\\\",\\\"ReasonCodes[9]\\\":\\\"\\\",\\\"ReasonCodes[4]\\\":\\\"\\\",\\\"ReasonName[17]\\\":\\\"\\\",\\\"nocard_check\\\":\\\"Y\\\",\\\"DecisionResult\\\":\\\"\\\",\\\"ruidai_credit_limit\\\":0.0,\\\"ReasonName[13]\\\":\\\"\\\",\\\"nocard_putout_status\\\":\\\"\\\",\\\"ReasonCodeDescs[1]\\\":\\\"A\\\",\\\"ReasonCodes[19]\\\":\\\"\\\",\\\"ReasonCodeDescs[16]\\\":\\\"\\\",\\\"ReasonCodeDescs[5]\\\":\\\"\\\",\\\"ReasonCodeDescs[8]\\\":\\\"\\\",\\\"ReasonCodes[11]\\\":\\\"\\\",\\\"nocard_status\\\":\\\"\\\",\\\"ReasonCodeDescs[11]\\\":\\\"\\\",\\\"ReasonCodes[15]\\\":\\\"\\\",\\\"exp_c2_user_type\\\":\\\"4\\\",\\\"ReasonName[2]\\\":\\\"瑞贷通过\\\",\\\"ReasonName[10]\\\":\\\"\\\",\\\"ReasonCodes[8]\\\":\\\"\\\",\\\"ReasonName[6]\\\":\\\"\\\",\\\"queryid\\\":\\\"u_n2z1rwu\\\",\\\"ReasonCodes[3]\\\":\\\"1005\\\",\\\"ReasonName[18]\\\":\\\"\\\",\\\"ReasonName[14]\\\":\\\"\\\",\\\"ReasonCodes[16]\\\":\\\"\\\",\\\"ReasonCodeDescs[15]\\\":\\\"\\\",\\\"ReasonCodeDescs[4]\\\":\\\"\\\",\\\"ReasonCodeDescs[19]\\\":\\\"\\\"}]\",\"costtime\":\"4\",\"errormsg\":\"\",\"partner\":\"\",\"query_time\":\"2020-03-12 11:52:50\",\"computevariables\":\"{\\\"rd_putout_status\\\":\\\"-2\\\",\\\"fd_order_status\\\":\\\"-2\\\",\\\"c2_user_type\\\":\\\"4\\\",\\\"nc_putout_status\\\":\\\"-2\\\",\\\"nc_credit_limit\\\":0.0,\\\"rd_credit_limit\\\":0.0,\\\"nc_active_status\\\":\\\"-2\\\",\\\"fd_credit_limit\\\":0,\\\"c2_white_active_status\\\":\\\"-2\\\",\\\"rd_active_status\\\":\\\"-2\\\"}\"}";
//        String msg1 = "{\"serialid\":\"84f018fa4eba48c481e477fba1b5baa9\",\"businessid\":\"loan-mutex\",\"queryparma\":{\"businessId\":\"loan-mutex\",\"conditions\":[{\"queryId\":[\"u_n2z1rwu\"],\"queryType\":[\"11\"]}]},\"qaccount\":\"data_team\",\"code\":\"0\",\"data\":[{\"ReasonCodes[20]\":\"\",\"ReasonCodeDescs[10]\":\"\",\"ReasonName[1]\":\"福贷通过\",\"ReasonCodes[12]\":\"\",\"ReasonCodeDescs[14]\":\"\",\"ruidai_status\":\"\",\"ReasonName[5]\":\"\",\"ReasonName[11]\":\"\",\"ReasonCodes[7]\":\"\",\"ReasonName[9]\":\"\",\"ReasonName[19]\":\"\",\"fudai_status\":\"100010\",\"ReasonCodes[6]\":\"\",\"ReasonName[15]\":\"\",\"Version\":\"FDANDRUI-20191224-V8\",\"ReasonCodes[2]\":\"1001\",\"ReasonCodes[17]\":\"\",\"ReasonCodeDescs[18]\":\"\",\"ruidai_new_user\":\"1\",\"ReasonCodeDescs[3]\":\"A\",\"ReasonCodeDescs[7]\":\"\",\"ruidai_putout_status\":\"\",\"ReasonCodes[13]\":\"\",\"ReasonCodeDescs[13]\":\"\",\"ReasonName[4]\":\"\",\"ReasonName[12]\":\"\",\"ReasonName[20]\":\"\",\"ReasonName[8]\":\"\",\"ReasonCodes[5]\":\"\",\"nocard_credit_limit\":0.0,\"fudai_credit_limit\":0.0,\"ruidai_check\":\"Y\",\"ReasonName[16]\":\"\",\"DecisionResultCodes\":\"\",\"ReasonCodes[1]\":\"1003\",\"ReasonCodeDescs[17]\":\"\",\"ReasonCodeDescs[2]\":\"A\",\"ReasonCodes[18]\":\"\",\"ReasonCodeDescs[6]\":\"\",\"ReasonCodeDescs[20]\":\"\",\"ReasonCodeDescs[9]\":\"\",\"ReasonCodes[10]\":\"\",\"fudai_orig_status\":\"-2\",\"fudai_new_user\":\"1\",\"ReasonCodeDescs[12]\":\"\",\"ReasonCodes[14]\":\"\",\"ReasonName[3]\":\"无卡瑞贷通过\",\"nocard_new_user\":\"1\",\"fudai_check\":\"Y\",\"ReasonName[7]\":\"\",\"ReasonCodes[9]\":\"\",\"ReasonCodes[4]\":\"\",\"ReasonName[17]\":\"\",\"nocard_check\":\"Y\",\"DecisionResult\":\"\",\"ruidai_credit_limit\":0.0,\"ReasonName[13]\":\"\",\"nocard_putout_status\":\"\",\"ReasonCodeDescs[1]\":\"A\",\"ReasonCodes[19]\":\"\",\"ReasonCodeDescs[16]\":\"\",\"ReasonCodeDescs[5]\":\"\",\"ReasonCodeDescs[8]\":\"\",\"ReasonCodes[11]\":\"\",\"nocard_status\":\"\",\"ReasonCodeDescs[11]\":\"\",\"ReasonCodes[15]\":\"\",\"exp_c2_user_type\":\"4\",\"ReasonName[2]\":\"瑞贷通过\",\"ReasonName[10]\":\"\",\"ReasonCodes[8]\":\"\",\"ReasonName[6]\":\"\",\"queryid\":\"u_n2z1rwu\",\"ReasonCodes[3]\":\"1005\",\"ReasonName[18]\":\"\",\"ReasonName[14]\":\"\",\"ReasonCodes[16]\":\"\",\"ReasonCodeDescs[15]\":\"\",\"ReasonCodeDescs[4]\":\"\",\"ReasonCodeDescs[19]\":\"\"}],\"costtime\":\"4\",\"errormsg\":\"\",\"partner\":\"\",\"query_time\":\"2020-03-12 11:52:50\",\"computevariables\":{\"rd_putout_status\":\"-2\",\"fd_order_status\":\"-2\",\"c2_user_type\":\"4\",\"nc_putout_status\":\"-2\",\"nc_credit_limit\":0.0,\"rd_credit_limit\":0.0,\"nc_active_status\":\"-2\",\"fd_credit_limit\":0,\"c2_white_active_status\":\"-2\",\"rd_active_status\":\"-2\"}}";
//
//        String msg3 = " {\n" +
//                " \"rowData\":\"{\\\"user_id\\\":\\\"9527\\\",\\\"update_time\\\":\\\"2019-09-05 11:44:25\\\"}\",\n" +
//                "   \"age\":62,\n" +
//                "   \"cars\": [\n" +
//                "\t  { \"name\":\"Porsche\",  \"models\":[ \"911\", \"Taycan\" ] },\n" +
//                "\t  { \"name\":\"BMW\", \"models\":[ \"M5\", \"M3\", \"X5\" ] },\n" +
//                "\t  { \"name\":\"Volvo\", \"models\":[ \"XC60\", \"V60\" ] }\n" +
//                "   ]\n" +
//                "}";
//        String msg4 = "{\"serialid\":\"84f018fa4eba48c481e477fba1b5baa9\",\"businessid\":\"loan-mutex\",\"queryparma\":{\"businessId\":\"loan-mutex\",\"conditions\":[{\"queryId\":[\"u_n2z1rwu\"],\"queryType\":[\"11\"]}]},\"qaccount\":\"data_team\",\"code\":\"0\",\"data\":\"[{\"ReasonCodes[24]\":\"\",\"ReasonCodes[12]\":\"\",\"ReasonCodeDescs[14]\":\"\",\"ReasonCodes[48]\":\"\",\"ReasonCodes[36]\":\"\",\"exp_yh_gang_loan_user_risk_jud\":\"0\",\"ReasonName[5]\":\"\",\"ReasonName[99]\":\"\",\"ReasonName[75]\":\"\",\"ReasonCodes[80]\":\"\",\"ReasonName[87]\":\"\",\"ReasonCodes[7]\":\"\",\"ReasonName[51]\":\"\",\"ReasonCodeDescs[82]\":\"\",\"ReasonName[63]\":\"\",\"ReasonCodes[92]\":\"\",\"ReasonCodeDescs[94]\":\"\",\"ReasonCodeDescs[70]\":\"\",\"ReasonName[19]\":\"\",\"ReasonCodes[6]\":\"\",\"hit_riskrules_cnt\":0.0,\"ReasonCodes[49]\":\"\",\"ReasonCodeDescs[26]\":\"\",\"ReasonCodeDescs[38]\":\"\",\"exp_zj_hit_suid_med_ord_risklist_jud\":\"0\",\"exp_yh_message_combine_1_jud\":\"-1\",\"ReasonCodes[13]\":\"\",\"ReasonCodeDescs[13]\":\"\",\"ReasonCodeDescs[25]\":\"\",\"exp_yh_bank_dk_overdue_all_cnt\":-1.0,\"ReasonCodes[37]\":\"\",\"ReasonCodes[25]\":\"\",\"ReasonName[88]\":\"\",\"ReasonName[4]\":\"\",\"ReasonName[64]\":\"\",\"exp_zj_hit_phone_med_ord_risklist_jud\":\"0\",\"ReasonName[76]\":\"\",\"ReasonName[40]\":\"\",\"ReasonCodes[93]\":\"\",\"ReasonCodeDescs[93]\":\"\",\"ReasonName[52]\":\"\",\"ReasonCodes[81]\":\"\",\"exp_lo_hit_geohash_risklist_jud\":\"0\",\"ReasonCodeDescs[81]\":\"\",\"ReasonCodes[5]\":\"\",\"exp_yh_userkn_phone_combine_1_jud\":\"0\",\"exp_yh_ip_plus_combine_6_jud\":\"0\",\"exp_yh_userkn_phone_4_4_hhi\":0.1429,\"exp_yh_fd_fill_info_wifi_frequent_wifi_jud\":\"-1\",\"ReasonCodes[38]\":\"\",\"ReasonCodeDescs[37]\":\"\",\"ReasonCodeDescs[49]\":\"\",\"ReasonCodes[22]\":\"\",\"ReasonCodes[10]\":\"\",\"ReasonCodeDescs[24]\":\"\",\"ReasonCodes[46]\":\"\",\"ReasonCodes[34]\":\"\",\"ReasonCodeDescs[36]\":\"\",\"ReasonCodeDescs[12]\":\"\",\"ReasonCodes[58]\":\"\",\"ReasonName[77]\":\"\",\"ReasonName[89]\":\"\",\"ReasonName[3]\":\"\",\"ReasonName[53]\":\"\",\"ReasonName[65]\":\"\",\"ReasonCodes[90]\":\"\",\"ReasonName[41]\":\"\",\"ReasonCodes[9]\":\"\",\"ReasonCodeDescs[80]\":\"\",\"ReasonCodeDescs[92]\":\"\",\"exp_yh_userkn_name_unusual_rate_jud\":\"0\",\"exp_yh_ip_plus_combine_9_jud\":\"0\",\"ReasonCodeDescs[48]\":\"\",\"exp_zj_hit_employer_tel_med_hig_risklist_jud\":\"0\",\"ReasonCodes[11]\":\"\",\"ReasonCodes[35]\":\"\",\"ReasonCodeDescs[35]\":\"\",\"exp_zj_hit_udid_med_hig_risklist_jud\":\"0\",\"ReasonCodes[23]\":\"\",\"ReasonCodeDescs[47]\":\"\",\"ReasonCodeDescs[11]\":\"\",\"ReasonCodes[59]\":\"\",\"ReasonCodeDescs[23]\":\"\",\"ReasonCodes[47]\":\"\",\"ReasonName[66]\":\"\",\"ReasonName[78]\":\"\",\"exp_yh_userkn_phone_isp_rate\":0.0,\"ReasonName[42]\":\"\",\"ReasonCodes[91]\":\"\",\"ReasonName[2]\":\"\",\"ReasonName[54]\":\"\",\"ReasonCodes[8]\":\"\",\"ReasonName[30]\":\"\",\"ReasonCodeDescs[91]\":\"\",\"exp_yh_userkn_phone_head_7_hhi\":0.1429,\"exp_yh_nonbank_dk_overdue_all_cnt\":-1.0,\"exp_yh_ip_plus_combine_2_jud\":\"0\",\"ReasonCodeDescs[59]\":\"\",\"ReasonCodeDescs[10]\":\"\",\"ReasonCodes[96]\":\"\",\"ReasonName[1]\":\"\",\"ReasonCodeDescs[46]\":\"\",\"ReasonCodeDescs[58]\":\"\",\"ReasonCodeDescs[22]\":\"\",\"ReasonCodeDescs[34]\":\"\",\"exp_yh_userkn_phone_head_5_hhi_jud\":\"0\",\"ReasonCodeDescs[90]\":\"\",\"exp_yh_hit_risk_ip_blacklist_jud\":\"0\",\"ReasonCodes[60]\":\"\",\"ReasonName[95]\":\"\",\"ReasonName[71]\":\"\",\"ReasonCodes[84]\":\"\",\"ReasonCodes[72]\":\"\",\"ReasonName[83]\":\"\",\"ReasonName[39]\":\"\",\"ReasonName[15]\":\"\",\"ReasonName[27]\":\"\",\"exp_yh_hit_risk_ip_gps_2_jud\":\"0\",\"ReasonCodes[17]\":\"\",\"exp_yh_userkn_phone_head_9_hhi\":0.1429,\"exp_yh_nonbank_dk_overdue_6m_cnt\":-1.0,\"ReasonCodes[29]\":\"\",\"ReasonCodes[97]\":\"\",\"ReasonCodeDescs[21]\":\"\",\"ReasonCodes[85]\":\"\",\"exp_yh_userkn_phone_7_4_hhi_jud\":\"0\",\"ReasonCodeDescs[57]\":\"\",\"ReasonCodeDescs[69]\":\"\",\"ReasonCodeDescs[33]\":\"\",\"ReasonCodeDescs[45]\":\"\",\"ReasonName[84]\":\"\",\"ReasonName[96]\":\"\",\"ReasonName[60]\":\"\",\"ReasonCodes[73]\":\"\",\"ReasonCodes[61]\":\"\",\"ReasonName[72]\":\"\",\"ReasonName[28]\":\"\",\"ReasonName[16]\":\"\",\"exp_yh_ip_plus_combine_7_jud\":\"0\",\"exp_yh_ip_plus_accuracy\":\"街道\",\"ReasonCodes[18]\":\"\",\"ReasonCodeDescs[101]\":\"\",\"exp_yh_fd_bind_phone_wifi_frequent_wifi_jud\":\"-1\",\"exp_yh_userkn_phone_7_4_hhi\":0.1429,\"ReasonCodeDescs[20]\":\"\",\"ReasonCodeDescs[9]\":\"\",\"ReasonCodeDescs[32]\":\"\",\"ReasonCodeDescs[68]\":\"\",\"ReasonCodes[26]\":\"\",\"ReasonCodeDescs[44]\":\"\",\"ReasonCodes[14]\":\"\",\"ReasonCodeDescs[56]\":\"\",\"ReasonName[97]\":\"\",\"ReasonName[73]\":\"\",\"ReasonCodes[82]\":\"\",\"ReasonCodes[70]\":\"\",\"ReasonName[85]\":\"\",\"ReasonName[61]\":\"\",\"ReasonCodes[94]\":\"\",\"ReasonName[17]\":\"\",\"ReasonName[29]\":\"\",\"ReasonCodes[39]\":\"\",\"ReasonCodes[27]\":\"\",\"ReasonCodeDescs[8]\":\"\",\"ReasonCodeDescs[31]\":\"\",\"ReasonCodeDescs[43]\":\"\",\"ReasonCodeDescs[79]\":\"\",\"exp_yh_userkn_phone_head_8_hhi\":0.1429,\"exp_yh_rpa_risk_label_jud\":\"0\",\"ReasonCodes[15]\":\"\",\"ReasonCodeDescs[55]\":\"\",\"ReasonCodeDescs[67]\":\"\",\"exp_yh_ip_plus_combine_3_jud\":\"0\",\"exp_yh_ip_plus_combine_10_jud\":\"0\",\"ReasonName[86]\":\"\",\"ReasonName[98]\":\"\",\"ReasonName[62]\":\"\",\"ReasonCodes[71]\":\"\",\"ReasonName[74]\":\"\",\"ReasonCodes[95]\":\"\",\"ReasonName[50]\":\"\",\"ReasonCodes[83]\":\"\",\"exp_yh_bank_dk_overdue_6m_cnt\":-1.0,\"ReasonName[18]\":\"\",\"ReasonCodes[28]\":\"\",\"ReasonCodes[16]\":\"\",\"exp_zj_hit_employer_tel_med_ord_risklist_jud\":\"0\",\"ReasonCodeDescs[42]\":\"\",\"ReasonCodes[64]\":\"\",\"ReasonName[91]\":\"\",\"ReasonCodes[52]\":\"\",\"ReasonCodeDescs[54]\":\"\",\"ReasonCodes[88]\":\"\",\"ReasonCodeDescs[30]\":\"\",\"ReasonCodes[76]\":\"\",\"ReasonCodes[100]\":\"\",\"ReasonCodeDescs[66]\":\"\",\"ReasonCodeDescs[78]\":\"\",\"exp_yh_fd_ocr_wifi_frequent_wifi_jud\":\"-1\",\"ReasonName[11]\":\"\",\"ReasonName[23]\":\"\",\"ReasonCodes[40]\":\"\",\"exp_yh_ip_plus_combine_4_jud\":\"0\",\"ReasonName[59]\":\"\",\"ReasonName[35]\":\"\",\"ReasonName[47]\":\"\",\"ReasonCodeDescs[7]\":\"\",\"ReasonCodes[53]\":\"\",\"ReasonCodeDescs[53]\":\"\",\"ReasonName[80]\":\"\",\"ReasonCodes[41]\":\"\",\"ReasonCodeDescs[65]\":\"\",\"ReasonName[92]\":\"\",\"ReasonName[100]\":\"\",\"ReasonCodes[77]\":\"\",\"ReasonCodeDescs[41]\":\"\",\"ReasonCodes[65]\":\"\",\"exp_yh_userkn_name_unusual_rate\":1.0,\"ReasonCodes[89]\":\"\",\"ReasonCodes[101]\":\"\",\"ReasonCodeDescs[77]\":\"\",\"ReasonCodeDescs[89]\":\"\",\"ReasonName[12]\":\"\",\"exp_yh_ip_plus_combine_8_jud\":\"0\",\"ReasonName[48]\":\"\",\"ReasonName[24]\":\"\",\"ReasonName[36]\":\"\",\"exp_yh_user_5geohash_cnt\":1.0,\"exp_yh_fd_ocr_wifi_bind_phone_wifi_jud\":\"-1\",\"SerVersion\":\"BD-FQZZR-FRC-1125-V4.2\",\"ReasonCodeDescs[6]\":\"\",\"ReasonCodeDescs[64]\":\"\",\"ReasonCodes[86]\":\"\",\"ReasonCodes[74]\":\"\",\"ReasonCodeDescs[76]\":\"\",\"ReasonName[81]\":\"\",\"ReasonCodeDescs[40]\":\"\",\"ReasonCodeDescs[52]\":\"\",\"ReasonCodes[98]\":\"\",\"ReasonCodeDescs[88]\":\"\",\"exp_yh_user_4geohash_cnteasonCodes[75]\":\"\",\"ReasonCodeDescs[75]\":\"\",\"ReasonCodes[63]\":\"\",\"ReasonName[70]\":\"\",\"ReasonCodeDescs[87]\":\"\",\"ReasonCodeDescs[51]\":\"\",\"ReasonCodes[99]\":\"\",\"ReasonCodeDescs[63]\":\"\",\"ReasonCodes[87]\":\"\",\"exp_yh_ip_gps_distance\":565.0,\"ReasonCodeDescs[99]\":\"\",\"suggest\":\"01\",\"ReasonCodes[51]\":\"\",\"ReasonName[82]\":\"\",\"exp_zj_hit_idcard_med_hig_risklist_jud\":\"0\",\"ReasonName[94]\":\"\",\"exp_zj_hit_phone_med_hig_risklist_jud\":\"0\",\"ReasonName[26]\":\"\",\"ReasonName[38]\":\"\",\"ReasonName[14]\":\"\",\"ReasonCodeDescs[4]\":\"\",\"ReasonCodeDescs[19]\":\"\",\"ReasonCodes[20]\":\"\",\"ReasonCodeDescs[86]\":\"\",\"ReasonCodeDescs[98]\":\"\",\"ReasonCodes[44]\":\"\",\"ReasonCodeDescs[62]\":\"\",\"ReasonCodes[32]\":\"\",\"ReasonCodeDescs[74]\":\"\",\"ReasonCodes[68]\":\"\",\"ReasonCodes[56]\":\"\",\"exp_yh_ip_plus_combine_5_jud\":\"0\",\"ReasonName[55]\":\"\",\"ReasonName[67]\":\"\",\"exp_yh_userkn_phone_head_9_hhi_jud\":\"1\",\"ReasonName[31]\":\"\",\"ReasonName[43]\":\"\",\"ReasonName[9]\":\"\",\"ReasonCodeDescs[50]\":\"\",\"ReasonName[79]\":\"\",\"ReasonCodes[2]\":\"\",\"ReasonCodeDescs[18]\":\"\",\"ReasonCodeDescs[3]\":\"\",\"ReasonCodeDescs[97]\":\"\",\"exp_yh_fd_ocr_wifi_fill_info_wifi_jud\":\"-1\",\"ReasonCodes[33]\":\"\",\"ReasonCodeDescs[73]\":\"\",\"ReasonCodes[21]\":\"\",\"ReasonCodeDescs[85]\":\"\",\"ReasonCodes[57]\":\"\",\"ReasonCodes[45]\":\"\",\"ReasonCodes[69]\":\"\",\"ReasonName[44]\":\"\",\"ReasonName[56]\":\"\",\"ReasonName[20]\":\"\",\"ReasonName[32]\":\"\",\"exp_yh_user_call_log_group\":\"0\",\"ReasonName[8]\":\"\",\"ReasonCodeDescs[61]\":\"\",\"DecisionResultCodes\":\"X\",\"ReasonCodes[1]\":\"\",\"ReasonName[68]\":\"\",\"ReasonCodeDescs[17]\":\"\",\"ReasonCodeDescs[29]\":\"\",\"ReasonCodeDescs[2]\":\"\",\"hit_hrisk_riskrules_cnt\":0.0,\"exp_yh_change_udid_wifi_frequent_wifi_jud\":\"-1\",\"ReasonCodes[42]\":\"\",\"exp_yh_id_linked_by_udid_risk_jud\":\"0\",\"ReasonCodes[30]\":\"\",\"ReasonCodes[66]\":\"\",\"ReasonCodeDescs[84]\":\"\",\"exp_yh_userkn_phone_head_6_hhi\":0.1429,\"ReasonCodes[54]\":\"\",\"ReasonCodeDescs[96]\":\"\",\"ReasonCodes[78]\":\"\",\"ReasonName[33]\":\"\",\"ReasonName[45]\":\"\",\"exp_yh_ip_plus_combine_1_jud\":\"0\",\"ReasonName[21]\":\"\",\"ReasonCodeDescs[60]\":\"\",\"ReasonCodeDescs[72]\":\"\",\"ReasonName[7]\":\"\",\"ReasonCodes[4]\":\"\",\"exp_zj_hit_udid_med_ord_risklist_jud\":\"0\",\"exp_yh_hit_risk_ip_gps_jud\":\"0\",\"ReasonName[57]\":\"\",\"ReasonName[69]\":\"\",\"ReasonCodeDescs[28]\":\"\",\"exp_yh_userkn_phone_unusual_rate\":1.0,\"exp_yh_bad_wifi_mac_jud\":\"0\",\"ReasonCodeDescs[1]\":\"\",\"ReasonCodeDescs[16]\":\"\",\"ReasonCodes[31]\":\"\",\"ReasonCodes[55]\":\"\",\"ReasonCodeDescs[95]\":\"\",\"ReasonCodes[43]\":\"\",\"ReasonName[90]\":\"\",\"ReasonCodes[79]\":\"\",\"ReasonCodes[67]\":\"\",\"hit_rej_riskrules_cnt\":0.0,\"ReasonName[22]\":\"\",\"ReasonName[34]\":\"\",\"exp_zj_hit_idcard_med_ord_risklist_jud\":\"0\",\"ReasonName[10]\":\"\",\"ReasonCodeDescs[71]\":\"\",\"ReasonCodeDescs[83]\":\"\",\"ReasonName[6]\":\"\",\"ReasonCodes[3]\":\"\",\"exp_yh_userkn_phone_unusual_rate_jud\":\"0\",\"ReasonName[46]\":\"\",\"ReasonName[58]\":\"\",\"ReasonCodeDescs[39]\":\"\",\"exp_zj_hit_suid_med_hig_risklist_jud\":\"0\",\"ReasonCodeDescs[15]\":\"\",\"ReasonCodeDescs[27]\":\"\"}]\",\"costtime\":\"4\",\"errormsg\":\"\",\"partner\":\"\",\"query_time\":\"2020-03-12 11:52:50\",\"computevariables\":{\"rd_putout_status\":\"-2\",\"fd_order_status\":\"-2\",\"c2_user_type\":\"4\",\"nc_putout_status\":\"-2\",\"nc_credit_limit\":0.0,\"rd_credit_limit\":0.0,\"nc_active_status\":\"-2\",\"fd_credit_limit\":0,\"c2_white_active_status\":\"-2\",\"rd_active_status\":\"-2\"}}";
//
//        JSONObject jsonObject = JSONObject.parseObject(msg4);
//        System.out.println(getValue(jsonObject, "rowData.user_id", null));
//        System.out.println(getValue(jsonObject, "cars[0].name", null));
//        System.out.println(getValue(jsonObject, "cars[2].sex[0]", null));


        System.out.println(new Timestamp(System.currentTimeMillis()));
    }


    public String getValue(JSONObject jsonObject, String exp, String defaultValue) {
        try {
            Object object = jsonObject;
            String[] expArr = exp.split("\\.");
            for (int i = 0; i < expArr.length; i++) {
                if (i == expArr.length - 1) {
                    Pattern p = Pattern.compile("(\\[[^\\]]*\\])");
                    Matcher m = p.matcher(expArr[i]);
                    String resVal = null;
                    if (m.find()) {
                        String index = m.group(0).substring(1, m.group().length() - 1);
                        String filedName = expArr[i].split("\\[")[0];
                        resVal = ((JSONObject) object).getJSONArray(filedName).getString(Integer.valueOf(index));
                    }else {
                        resVal = ((JSONObject) object).getString(expArr[i]);
                    }
                    return resVal;
                }
                Pattern p = Pattern.compile("(\\[[^\\]]*\\])");
                Matcher m = p.matcher(expArr[i]);
                if (m.find()) {
                    String index = m.group(0).substring(1, m.group().length() - 1);
                    String filedName = expArr[i].split("\\[")[0];
                    Object tempObject = ((JSONObject) object).getJSONArray(filedName).get(Integer.valueOf(index));
                    if (null == tempObject) {
                        return defaultValue;
                    }
                    object = tempObject;
                } else {
                    Object tempObject = ((JSONObject) object).getJSONObject(expArr[i]);
                    if (null == tempObject) {
                        return defaultValue;
                    }
                    object = tempObject;
                }
            }
        } catch (Exception e) {

        }
        return defaultValue;
    }


    @Test
    public void test8() throws Exception {

        Pattern p = Pattern.compile("(\\[[^\\]]*\\])");
        Matcher m = p.matcher("name[1]");
        if (m.find()) {
            System.out.println(m.group(0).substring(1, m.group().length() - 1));
            System.out.println("name[1]".split("\\[")[0]);

        }

        List<String> list = new ArrayList<>();
        Map<String,String>  map = new HashMap<>();
//        new PriorityQueue<>()
        map.put("ssss","ssss");
        System.out.println( 7 & 9);
        list.add("ssss");
        list.add("jjjj");
        for (String s : list){
            System.out.println(s);
        }

        System.out.println( 10 >> 1);
    }


}
